<template>
  <div>
    <el-container>
      <el-header class="homeHeader">
        <div class="title">互联网医疗服务后台管理 (v1.0)</div>
        <el-dropdown class="userInfo"
                     @command="commandHeader">
          <span class="el-dropdown-link"
                style="margin-top: 5px">
            <img src="../../static/icon/用户logo.png">
            <i style="color: #eaeaea; font-size: 40px; margin-bottom: 50px">&nbsp;&nbsp;{{user.name}}</i>
          </span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item command="userInfo">个人中心</el-dropdown-item>
            <el-dropdown-item command="logout">注销</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </el-header>

      <el-container>
        <el-aside width="200px">
          <el-menu router
                   unique-opened
                   class="el-menu-vertical-demo">
            <el-menu-item index="/index/home">
              <i class="iconfont icon-shouye"></i>
              <span slot="title">首页</span>
            </el-menu-item>

            <el-submenu index="1">
              <template slot="title">
                <i class="iconfont icon-yisheng"></i>
                <span slot="title">医生管理</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="/index/server/screen">服务审核</el-menu-item>
                <el-menu-item index="/index/doctor/screen">医生审核</el-menu-item>
                <el-menu-item index="/index/doctor/list">医生列表</el-menu-item>
                <el-menu-item index="">医生详情</el-menu-item>
              </el-menu-item-group>
            </el-submenu>

            <el-menu-item index="/index/user-management">
              <i class="iconfont icon-yonghu"></i>
              <span slot="title">用户管理</span>
            </el-menu-item>

            <el-menu-item index="/index/prescription">
              <template slot="title">
                <i class="iconfont icon-chufang"></i>
                <span slot="title">处方管理</span>
              </template>
            </el-menu-item>

            <el-submenu index="4">
              <template slot="title">
                <i class="iconfont icon-dingdan"></i>
                <span slot="title">订单管理</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="/index/GuahaoOrder">挂号单管理</el-menu-item>
                <el-menu-item index="/index/medicineorder">药品订单管理</el-menu-item>
                <el-menu-item index="/index/prescriptionOrder">处方流转订单管理</el-menu-item>
                <el-menu-item index="/index/refund-order">退款申请</el-menu-item>
                <el-menu-item index="/index/interogationOrderManagement">问诊单管理</el-menu-item>
              </el-menu-item-group>
            </el-submenu>

            <el-submenu index="5">
              <template slot="title">
                <i class="iconfont icon-caiwu"></i>
                <span slot="title">财务管理</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="/index/tradingRecord">交易记录</el-menu-item>
                <el-menu-item index="/index/settleManagement">结算管理</el-menu-item>
                <el-menu-item index="/index/transferManagement">转账管理</el-menu-item>
              </el-menu-item-group>
            </el-submenu>

            <el-submenu index="6">
              <template slot="title">
                <i class="iconfont icon-yaopin"></i>
                <span slot="title">商品管理</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="/index/allmedicine">药品列表</el-menu-item>
                <el-menu-item index="/index/medicinecategory">药品分类</el-menu-item>
                <el-menu-item index="/index/medicinepass">药品审核</el-menu-item>
              </el-menu-item-group>
            </el-submenu>

            <el-submenu index="7">
              <template slot="title">
                <i class="iconfont icon-neirong"></i>
                <span slot="title">内容管理</span>
              </template>

              <el-menu-item-group>
                <el-menu-item index="/index/common-problem">常见问题</el-menu-item>
                <el-menu-item index="/index/PlatformDepartmentManagement">平台科室管理</el-menu-item>
                <el-menu-item index="/index/hospitalManagement">医院管理</el-menu-item>
                <el-menu-item index="/index/drugstoreManagement">药店管理</el-menu-item>
                <el-menu-item index="/index/departments">医院科室管理</el-menu-item>
                <el-menu-item index="">医院详情</el-menu-item>
              </el-menu-item-group>
            </el-submenu>

            <el-submenu index="8">
              <template slot="title">
                <i class="iconfont icon-tongji"></i>
                <span slot="title">统计</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="/index/doctor-stat">医生统计</el-menu-item>
                <el-menu-item index="/index/transactionStat">交易统计</el-menu-item>
              </el-menu-item-group>
            </el-submenu>

            <el-submenu index="9">
              <template slot="title">
                <i class="iconfont icon-quanxian"></i>
                <span slot="title">权限</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="/index/members">成员管理</el-menu-item>
                <el-menu-item index="1-2">角色管理</el-menu-item>
                <el-menu-item index="/index/modify">修改资料</el-menu-item>
                <el-menu-item index="/index/log">操作日志</el-menu-item>
                <el-menu-item index="1-5">数据库管理</el-menu-item>
                <el-menu-item index="/index/CustomerServiceManagement">客服管理</el-menu-item>
              </el-menu-item-group>
            </el-submenu>

            <el-menu-item index="/index/feedback">
              <i class="iconfont icon-neirong"></i>
              <span slot="title">意见管理</span>
            </el-menu-item>
          </el-menu>
        </el-aside>

        <el-main>
          <router-view />
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  name: "Index",
  data () {
    return {
      user: {
        name: 'admin',
        userFace: ''
      }
    }
  },
  methods: {
    commandHeader (command) {
      console.log(command)
      //点击了注销按钮
      if (command === 'logout') {
        this.$confirm('此操作将退出登录, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$axios({
            method: 'get',
            url: '/logout',
          }).then(resp => {
            if (data.code === 200) {
              // 清空用户信息
              window.sessionStorage.removeItem("user");
              window.sessionStorage.removeItem("tokenStr");
              //清空菜单
              this.$store.commit("initRoutes", [])
              this.$router.push("/");
            } else {
              this.$message({
                type: 'error',
                message: '注销失败!'
              });
            }
          })
        }).catch(() => {
          this.$message({
            type: 'warning',
            message: '已取消退出'
          });
        });
        //点击了用户中心按钮
      } else if (command === 'userInfo') {

      }
    }
  }
}
</script>

<style>
.homeHeader {
  background-color: #108ee9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 15px;
  box-sizing: border-box;
}

.homeHeader .title {
  font-size: 30px;
  font-family: 楷体;
  color: #ffffff;
}
.homeHeader .userInfo {
  cursor: pointer;
}
.el-dropdown-link img {
  width: 40px;
  height: 40px;
  border-radius: 24px;
  margin-left: 20px;
  margin-top: 8px;
}
</style>
